﻿using System;
using System.Data;
using System.Data.Objects;
using System.Data.Objects.DataClasses;

namespace AceSoft.RetailPlus.DBConnection
{
    /// <summary>
    /// This is not testable. This is just an extension to facilitate ObjectContext and for expansion purposes.
    /// </summary>
    public partial class ERP : ObjectContext, IServiceBase
    {

        #region Constructors

        /// <summary>
        /// Initialize a new erp object with automatic connection to database.
        /// connectionString is also the context name container
        /// </summary>
        public ERP(string defaultContainerName)
            : base("Name=" + defaultContainerName, defaultContainerName)
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }

        /// <summary>
        /// Initialize a new erp object using an existing connection
        /// </summary>
        public ERP(System.Data.EntityClient.EntityConnection connection, string defaultContainerName)
            : base(connection, defaultContainerName)
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }

        #endregion
        
        #region Abstract Methods

        partial void OnContextCreated();

        #endregion

    }
}
